package reflect;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

public class ReflectDemo5 {
    public static void main(String[] args) throws ClassNotFoundException, NoSuchMethodException, InstantiationException, IllegalAccessException, InvocationTargetException {
        Class cls = Class.forName("reflect.Person");
        Object obj = cls.newInstance();
        Method method = cls.getMethod("say", String.class);
        method.invoke(obj,"你好");
        method = cls.getMethod("say",String.class,int.class);
        method.invoke(obj,"下雨啦",5);
    }
}
